package com.bubblegumproject.ogo.swing.form;

import com.bubblegumproject.ogo.swing.events.ErrorEvent;

/**
 * Action indicating a Form was not processed successfully.
 *
 * @author Azubuko Obele (buko.obele@gmail.com)
 */
public class FormFailure extends FormAction {

    private ErrorEvent error;

    public FormFailure(ErrorEvent error) {
        this.error = error;
    }

    public ErrorEvent getError() {
        return error;
    }

    public static FormFailure FormFailure(ErrorEvent error) {
        return new FormFailure(error);
    }

    public static FormFailure FormFailure(Form form, Throwable cause) {
        return new FormFailure(new ErrorEvent(form, cause));
    }

    public String toString() {
        return "[" + getClass().getSimpleName() + " error=" + error + "]";
    }
}
